﻿using PureMVC.Interfaces;
using SMS.Core.Controller.Commands;
using SMS.Core.Model;

namespace SMS.Core.Controller
{
    class ApplicationController : PureMVC.Core.Controller
    {
        #region Constructors

        protected ApplicationController()
            : base()
        {
            InitializeAppController();
        }

        #endregion

        #region Public Methods

        public static new IController Instance
        {
            get
            {
                if (m_instance == null)
                {
                    lock (m_staticSyncRoot)
                    {
                        if (m_instance == null) 
                            m_instance = new ApplicationController();
                    }
                }
                return m_instance;
            }
        }

        #endregion

        #region Private & Internal Methods

        /// <summary>
        /// This is where to put some command registrations.
        /// </summary>
        private void InitializeAppController()
        {
            RegisterCommand(ApplicationConstants.STARTUP, typeof(StartupCommand));
            RegisterCommand(ApplicationConstants.STARTUP_SUCCESS, typeof(StartupCommand));
            RegisterCommand(ApplicationConstants.SHUTDOWN, typeof(ShutdownCommand));
            RegisterCommand(ApplicationConstants.SHUTDOWN_SUCCESS, typeof(ShutdownCommand));
        }

        #endregion
    }
}
